package com.net.shop.car.manager.ui.personalcenter.dingdan;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.net.shop.car.manager.BaseActivity;
import com.net.shop.car.manager.R;
import com.net.shop.car.manager.api.model.Dingdan;
import com.net.shop.car.manager.api.model.OilCardDingDan;
import com.net.shop.car.manager.api.model.TuiKuanDingdan;

public class YoukaDingdanItem implements ExpandHolder {
	private ImageView btn;
	private TextView leftTxt1;
	private TextView leftTxt2;
	private TextView rightTxt1;
	private TextView rightTxt2;
	private BaseActivity baseActivity;

	public YoukaDingdanItem(BaseActivity baseActivity, View view) {
		leftTxt1 = (TextView) view
				.findViewById(R.id.dingdan_youka_item_lefttxt1);
		leftTxt2 = (TextView) view
				.findViewById(R.id.dingdan_youka_item_lefttxt2);
		rightTxt1 = (TextView) view
				.findViewById(R.id.dingdan_youka_item_righttxt1);
		rightTxt2 = (TextView) view
				.findViewById(R.id.dingdan_youka_item_righttxt2);
		btn = (ImageView) view.findViewById(R.id.dingdan_youka_item_btn);
	}

	@Override
	public void setOnExpandedListener(OnClickListener onClickListener) {
		btn.setOnClickListener(onClickListener);
	}

	public void setData(Dingdan dingdan,boolean isOpened) {
		if (dingdan instanceof TuiKuanDingdan) {
			TuiKuanDingdan tuiKuanDingdan = (TuiKuanDingdan) dingdan;
			leftTxt1.setText(tuiKuanDingdan.getGoodName());
			leftTxt2.setText(tuiKuanDingdan.getCreateDate());
			switch (tuiKuanDingdan.getRefundState()) {
			case 1:
				rightTxt1.setText("待审核");
				break;
			case 2:
				rightTxt1.setText("审核通过");
				break;
			case 3:
				rightTxt1.setText("拒绝退款");
				break;
			case 4:
				rightTxt1.setText("退款成功");
				break;
			case 5:
				rightTxt1.setText("退款失败");
				break;
			default:
				break;
			}
			rightTxt2.setText(tuiKuanDingdan.getOrderId());
		} else if (dingdan instanceof OilCardDingDan) {
			OilCardDingDan oilCardDingDan = (OilCardDingDan) dingdan;
			leftTxt1.setText(oilCardDingDan.getGoodName());
			leftTxt2.setText(oilCardDingDan.getCreateDate());
			switch (oilCardDingDan.getChongzhiState()) {
			case 0:
				rightTxt1.setText("正在办理充值");
				break;
			case 1:
				rightTxt1.setText("充值成功");
				break;

			default:
				break;
			}
			rightTxt2.setText(oilCardDingDan.getOilCardNum());
		}
		btn.setSelected(isOpened);
	}

	/**
	 * @param closed
	 */
	public void setBtnState(boolean open) {
		btn.setSelected(open);
	}

}
